#ifndef CTABLEUSER_H
#define CTABLEUSER_H

#include "AbstractTable.h"
#include <QSharedPointer>
#include <QDateTime>
#include <QDebug>

struct CUserInfo{
    QString userId;
    int role;
    QString userName;
    bool active;
    bool locked;
    int loginType;
    QDateTime lastLoginTime;

    friend QDebug operator<<(QDebug debug,const CUserInfo &info){

        debug<< "CUserInfo(" << info.userId << info.userName << ");";
        return debug;
    }
};

class CTableUser : public AbstractTable
{
    Q_OBJECT
    explicit CTableUser(QObject *parent = nullptr);
public:
    static CTableUser* getInstance();

    bool addUser(const CUserInfo &info);
    bool deleteUser(const QString &userId);
    bool updateUser(const CUserInfo &info);
    QSharedPointer<CUserInfo> userInfo(const QString &userId);
    QSharedPointer<QList<CUserInfo>> allUser();

    //单元格读写
    INT_CELL(role,setRole,"Id","Role")
    STRING_CELL(userName,setUserName,"Id","UserName")
    BOOL_CELL(active,setActive,"Id","Active")
    BOOL_CELL(locked,setLocked,"Id","Locked")
    INT_CELL(loginType,setLoginType,"Id","LoginType")
    STRING_CELL(lastLoginTime,setLastLoginTime,"Id","LastLoginTime")
};

#endif // CTABLEUSER_H
